<include file="public@header" />
</head>
<body>
	<div class="wrap">
        <form class="layui-form js-ajax-form" action="{:url('AdminIndex/addRecord')}">
            
          <div class="layui-form-item">
            <label class="layui-form-label">类目</label>
            <div class="layui-input-inline">
              <input type="text" name="title" required value="汇缴{:date('Ym',time())}" lay-verify="required" placeholder="请输入类目" autocomplete="off" class="layui-input">
            </div>
          </div>
          
          <div class="layui-form-item">
            <label class="layui-form-label" >金额</label>
            <div class="layui-input-inline">
              <input type="text" name="money" required  lay-verify="required" placeholder="请输入金额）" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">（例如：120.01,或者120)</div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">缴存日期</label>
            <div class="layui-input-inline">
              <input type="text" class="layui-input" name="create_time" id="pay_date">
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">类型：</label>
            <div class="layui-input-block">
              
              <input type="radio" name="type" value="1" title="缴存" checked>
              <input type="radio" name="type" value="2" title="提取" >
              <input type="radio" name="type" value="3" title="其他" >
            </div>
          </div>
            <div class="layui-form-item">
              <div class="layui-input-block">
                <input type="hidden" name="user_id" value="{$user_id}"/>

                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo">添加</button>
              </div>
            </div>
          </form>
        <ul class="layui-timeline">
            <if condition="$records neq null">
                <foreach name="records" item="vo">
                    <li class="layui-timeline-item">
                        <i class="layui-icon layui-timeline-axis">&#xe63f;</i>
                        <div class="layui-timeline-content layui-text">
                          <h3 class="layui-timeline-title">
                            
                                <if condition="$vo.type eq 1">
                                  <span class="">【缴存】</span>
                                  <elseif condition="$vo.type eq 2"/>
                                  <span style="color: red;">【提取】</span>
                                  <else/>
                                  【其他】
                                </if>
                          </h3>
                          <p style="font-size: 20px;">
                            <ul>
                              <li>缴存金额：{$vo.money/100}</li>
                              <li>缴存日期：{:date('Y-m-d',strtotime($vo.create_time))}</li>
                              <a class="layui-btn  layui-btn-danger layui-btn-xs" href="javascript:parent.openIframeLayer('{:url('AdminIndex/editRecord',array('id'=>$vo['id']))}','修改记录',{area: ['600px', '600px']});">修改</a><br>
                            </ul>
                          </p>
                        </div>
                      </li>
                </foreach>
                <else />
                <li class="layui-timeline-item">
                    <i class="layui-icon layui-timeline-axis">&#xe63f;</i>
                    <div class="layui-timeline-content layui-text">
                      <p style="font-size: 20px;">
                        暂无记录
                      </p>
                    </div>
                  </li>
            </if>
            
            
          </ul>
		<div class="pagination" style="margin-left: 35%;">{$page}</div>

    </div>
        <script src="__STATIC__/js/admin.js"></script>
        <script type="text/javascript">
          layui.use('form', function(){
            var form = layui.form;
            
            //监听提交
            form.on('submit(formDemo)', function(data){
            });
          });
            function editRecord(id,content){
                layui.use('layer', function(){
                  var layer = layui.layer;
                  
                  layer.prompt({title: '请输入修改内容', formType: 2}, function(text, index){
                    layer.close(index);
                    
                    $.get("{:url('AdminIndex/editRecord')}", 
                    {
                        id:id,
                        msg:text.replace(/\ +/g,"").replace(/[\r\n]/g,"")
                    }, function(res){
                      if(res.code==1){
                        layer.msg("修改成功")
                        setTimeout(function(){
                            window.location.reload();
                        },1000)
                      }
                    });
                  });
                }); 
                
            }

            layui.use('laydate', function(){
                  var laydate = layui.laydate;
                  
                  //执行一个laydate实例
                  laydate.render({
                    elem: '#pay_date' //指定元素
                  });
                });
        </script>
</body>
</html>